//
//  MSTradeConfirmPayView.m
//  SocietySale
//
//  Created by Mike on 16/11/14.
//  Copyright © 2016年 Mike. All rights reserved.
//

#import "MSTradeConfirmPayView.h"

@interface MSTradeConfirmPayView ()
@property (nonatomic, strong) UILabel *payLabel;
@end

@implementation MSTradeConfirmPayView

-(id)init
{
    self=[super init];
    if (self)
    {
        self.backgroundColor = [UIColor whiteColor];
        self.frame = CGRectMake(0, 0, SCREENWIDTH, 50);
        [self initUI];
    }
    return self;
}

- (void)initUI{
    self.payLabel = [self creatLabel:CGRectMake(12, 0, SCREEN_WIDTH, 50)];
}

//创建label
- (UILabel*)creatLabel:(CGRect)frame{
    UILabel *label = [[UILabel alloc] initWithFrame:frame];
    label.font = HeitiFont(13);
    label.textColor = kLightBlackColor;
    [self addSubview:label];
    return label;
}

- (void)setModel:(MSTradeModel *)model{
    _model = model;
    if ([_model.type isEqualToString:@"2"]){//求购
        NSString *price = [NSString stringWithFormat:@"您可获得： %@",model.tradePrice];
    }
    
    NSString *price = [NSString stringWithFormat:@"您需支付： %@",model.tradePrice];

    NSMutableAttributedString *priceAttstr = [[NSMutableAttributedString alloc] initWithString:price attributes:@{NSFontAttributeName:HeitiFont(15),NSForegroundColorAttributeName:kLightBlackColor}];
    
    NSTextAttachment *textAttachment = [[NSTextAttachment alloc] initWithData:nil ofType:nil];
    textAttachment.bounds = CGRectMake(0, -5, 20, 20);
    textAttachment.image = [UIImage imageNamed:@"coin"];
    NSAttributedString *attachmentString = [NSAttributedString attributedStringWithAttachment:textAttachment];
    [priceAttstr insertAttributedString:attachmentString atIndex:6];
    
    NSAttributedString *symbolStr = [[NSAttributedString alloc] initWithString:@" x " attributes:@{NSFontAttributeName:HeitiFont(13),NSForegroundColorAttributeName:kDarkGrayColor}];
    [priceAttstr insertAttributedString:symbolStr atIndex:7];
    
    NSAttributedString *suffixStr = [[NSAttributedString alloc] initWithString:@"  !剩余江湖币不足" attributes:@{NSFontAttributeName:HeitiFont(13),NSForegroundColorAttributeName:KRedColor}];
    [priceAttstr appendAttributedString:suffixStr];
    
    self.payLabel.attributedText = priceAttstr;
    
}

@end
